<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>消息管理</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<script type="text/javascript" src="/oa/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/oa/js/myDate.js"></script>
<script type="text/javascript" src="/oa/js/jquery-1.4.4.min.js"></script>
<link href="/oa/css/message.css" type="text/css" rel="stylesheet" />
<link href="/oa/css/style.css" type="text/css" rel="stylesheet" />

<script type="text/javascript">
	function topage(page) {
		var form = document.forms[0];
		form.currentpage.value = page;
		form.submit();
	}
	$(document)
			.ready(
					function(e) {
						$("#btnSelect")
								.click(
										function() {
											if ($("#startDate").val() == ""
													|| $("#endDate").val() == "") {
												alert("请选择开始和结束时间");
												return false;
											} else {
												var form = document.forms[0];
												form.action = '<s:url namespace="/messageManage" action="messageListByTime" />';
												form.submit();
											}
										});
						$("#selectDiv :text").focus(function() {
							this.blur();
						});
						$("#today").click(function() {
							$("#startDate").val(getNowDate());
							$("#endDate").val(getNowDate());
						});
						$("#week").click(function() {
							$("#startDate").val(getWeekStart());
							$("#endDate").val(getWeekEnd());
						});
						$("#mounth").click(function() {
							$("#startDate").val(getMonthStart());
							$("#endDate").val(getMonthEnd());
						});
					});
	function deleteMessage(id, name) {
		var sure = confirm("确定删除:" + name + " ？" );
		if (sure) {
			window.location.href = '<s:url action="deleteMessageToUser" namespace="/messageManage" />?deleteId='
					+ id;
		}
	}
	function showDetail(id) {
		window
				.open(
						'/oa/page/message/showMessage.jsp?id=' + id,
						"消息详情",
						"height=400, width=600, top=0, left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
	};
	function publish(id) {
		window.location.href = '<s:url action="publishMessage" namespace="/messageManage" />?publishId='+ id;
	};
	function update(id) {
		window.location.href = '<s:url action="showUpdateMessageToUser" namespace="/messageManage" />?showId='+ id;
	};
</script>
</head>

<body>
	<div>
		<s:form namespace="/messageManage" action="" id="messageForm">
			<s:hidden name="currentpage" />
			<div class="header">
				<p align="center">
					&nbsp; <b>消息管理</b>
				</p>
				<hr />
				<p>
					<b>请输入填写消息的时间</b>----
				</p>
				<p>
				<div id="selectDiv">
					选择日期:
					<s:textfield id="startDate" name="startDate"
						onclick="WdatePicker()" />
					---
					<s:textfield id="endDate" name="endDate" onclick="WdatePicker()" />
					<input type="radio" id="today" name="date" />本日 <input
						type="radio" id="week" name="date" />本周 <input type="radio"
						id="mounth" name="date" />本月 <input id="btnSelect" type="button"
						value="搜索" />
				</div>
				</p>
			</div>
			<div class="centerLine">
				<span><a href="/oa/page/message/addMessage.jsp">填写新消息</a> </span>
			</div>
			<div class="content">
				<table class="data_list_table" id="table_message">
					<tr>
						<th>消息标题</th>
						<th>消息类型</th>
						<th>消息内容</th>
						<th>创建者</th>
						<th>发送对象</th>
						<th>开始时间</th>
						<th>结束时间</th>
						<th>创建时间</th>
						<th>修改</th>
						<th>删除</th>
						<th>发布</th>
					</tr>
					<s:iterator value="pageView.records" status="entry">
						<tr>
							<td><label id="messageTitle" style="cursor: pointer;"
								onclick="showDetail( ${id})">${message.title}</label></td>
							<td>${message.messageType.title }消息</td>
							<td>${message.content }</td>
							<td>${fromUser.userName }</td>
							<td><s:if test="toUser == null">
								所有人
							</s:if> <s:elseif test="toUser != null ">
								特定对象
							</s:elseif>
							</td>
							<td><s:date name="message.beginTime "
									format="yyyy年MM月dd日 hh:mm:ss" /></td>
							<td><s:date name="message.endTime "
									format="yyyy年MM月dd日 hh:mm:ss" /></td>
							<td><s:date name="message.recordTime " format="yyyy年MM月dd日" />
							</td>
							<td><s:if test="message.ifPublish== 0">
									<img onclick="update( ${id})" title="编辑"  style="cursor: pointer;"
										src="/oa/images/bt_edit.gif" class="op_button" />
								</s:if> <s:else>
									<img title="修改" src="/oa/images/bt_edit.gif" class="op_button"  style="cursor:default; "/>
								</s:else></td>
							<td><img
								onclick="deleteMessage(' ${id}',' ${message.title}' )"
								title="删除" src="/oa/images/bt_del.gif" class="op_button" /></td>
							<td><s:if test="message.ifPublish==0">
									<input type="button" class="common_button" value="发 布" style="cursor: pointer;"
										onclick="publish(${id})" />
								</s:if> <s:else>
									<input type="button" class="common_button" value="发 布"
										disabled="disabled" />
								</s:else></td>
						</tr>
					</s:iterator>
					<tr>
						<th colspan="11" class="pager">
							<div class="pager">
								<s:include value="/page/share/paging.jsp"></s:include>
							</div></th>
					</tr>
				</table>
			</div>
		</s:form>
	</div>
</body>
</html>
